<?php

declare(strict_types=1);

namespace App\Entities;

class OrderItemEntity extends ABaseEntity
{
    public function __construct(OrderItemModel $model)
    {
        $this->model = $model;
    }

    /**
     * @return OrderItemEntity|null
     */
    public static function findByOrderId(int $orderId)
    {
        $orderItem = OrderItemModel::where('order_id', '=', $orderId)->first();
        if ($orderItem === null) {
            return null;
        }

        return new self($orderItem);
    }

    public function setOrderId(int $orderId)
    {
        $this->model->order_id = $orderId;
    }

    public function setProductId(int $productId)
    {
        $this->model->product_id = $productId;
    }

    /**
     * @return int
     */
    public function getProductId()
    {
        return $this->model->product_id;
    }

    public function setProductSkuId(int $productSkuId)
    {
        $this->model->product_sku_id = $productSkuId;
    }

    /**
     * @return int
     */
    public function getProductSkuId()
    {
        return $this->model->product_sku_id;
    }

    public function setPrice($price)
    {
        $this->model->price = $price;
    }

    public function setSquareMetre(int $squareMetre)
    {
        $this->model->square_metre = $squareMetre;
    }

    public function getSquareMetre()
    {
        return $this->model->square_metre;
    }
}
